package bitTest;

import java.nio.charset.StandardCharsets;

/**
 * 在Java中，字节数组通常用于处理二进制数据，如文件读写、网络传输等。例如，通过字节数组可以读取或写入文件的内容，
 * 也可以在网络中传输二进制数据。java程序编译的字节码也是字节数组
 */
public class StringToByte {
    public static void main(String[] args) {
        stringToByte();
    }
    public static void stringToByte() {
        byte[] bytes = {118,-54,63,97,-101,-58,118,105,-52,72,-115,27,24,40,-15,-50};
        String s = new String(bytes, StandardCharsets.ISO_8859_1);
        System.out.println(s);
        String s1 = new String(bytes,StandardCharsets.UTF_16);
        System.out.println(s1);
        byte[] bytes2 = {-26,-106,-71};
        String s2 = new String(bytes2);
        System.out.println(s2);
    }
}
